window.onload=function () {
  getusername();
	getcarbyid();
}
function GetQueryString(name)
{
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}
function  getcarbyid() {
	 $.ajax({
      url: 'http://172.18.21.150/ToGo/getCarById',
      type: 'post',
      dataType: 'json',
      data:{car_id:GetQueryString('car_id')},
      success:function (result) {
          if(result.status=='200'){
            var car=result.data;
            $('#theme').html(car.topic);
            $('#carinfo-price').html("￥"+car.price);
           $('#carinfo-category').html(car.category);
           $('#carinfo-mileage').html(car.mileage);
           $('#carinfo-buytime').html(car.buyingTime);
           $('#carinfo-originalprice').html(car.originalPrice);
           $('#carpic').html('<img src="http://172.18.21.150/'+car.photo+'"/>');
           var status;
           if(car.status=='0'){
           		status='待审核';
           }else if(car.status=='1'){
           		status='在售';
           }else{
           	status='已售';
           }
           $('#carinfo-status').html(status);

          }
      },
      error:function () {
        alert('error');
      }
    });
}

